﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hyjx.GF.Database
{
    /// <summary>
    /// 赣锋数据库上下文
    /// </summary>
    public class GFDbContext : DbContext
    {
        readonly bool _useConnectionString = false;
        readonly string _connectionString;

        /// <summary>
        /// 创建一个新的赣锋数据库上下文
        /// </summary>
        /// <param name="options">配置集</param>
        public GFDbContext(DbContextOptions<GFDbContext> options) : base(options)
        {
            _connectionString = string.Empty;
        }
        /// <summary>
        /// 创建一个新的赣锋数据库上下文
        /// </summary>
        /// <param name="connectionString">连接字符串</param>
        public GFDbContext(string connectionString)
        {
            _useConnectionString = true;
            _connectionString = connectionString;
        }

        /// <summary>
        /// 粉体报表
        /// </summary>
        public DbSet<PowderReportEntity> PowderReports { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            if (_useConnectionString)
                optionsBuilder.UseSqlite(_connectionString);
        }
    }
}
